home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / Toolbox / ProgressBars 1.0 / Sources / AppleEvents.c next >
Encoding:
Text File  |  1996-09-17  |  2.1 KB  |  111 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        AppleEventStuff.c
  3.  
  4.     Contains:    Handlers for the 4 "required" events
  5.  
  6.     Written by:    Chris White, Developer Technical Support
  7.     
  8.     Copyright:    © 1996 by Apple Computer, Inc., all rights reserved.
  9.     
  10.     Change History (most recent first):
  11.     
  12.             1/22/96            CW        First release
  13.  
  14. */
  15.  
  16.  
  17.  
  18.  
  19. // System Includes
  20.  
  21. #ifndef __APPLEEVENTS__
  22.     #include <AppleEvents.h>
  23. #endif
  24.  
  25.  
  26.  
  27.  
  28. // Application includes
  29.  
  30. #ifndef __BAREBONES__
  31.     #include "BareBones.h"
  32. #endif
  33.  
  34. #ifndef __PROTOTYPES__
  35.     #include "Prototypes.h"
  36. #endif
  37.  
  38.  
  39.  
  40.  
  41.  
  42. // Static Prototypes
  43. static pascal OSErr HandleOapp ( AEDescList* aevt, AEDescList* reply, long refCon );
  44. static pascal OSErr HandleQuit ( AEDescList* aevt, AEDescList* reply, long refCon );
  45. static pascal OSErr HandleOdoc ( AEDescList* aevt, AEDescList* reply, long refCon );
  46. static pascal OSErr HandlePdoc ( AEDescList* aevt, AEDescList* reply, long refCon );
  47.  
  48.  
  49.  
  50. #pragma segment Initialize
  51.  
  52. OSErr InstallAppleEventHandlers ( void )
  53. {
  54.     OSErr    theErr;
  55.     
  56.     
  57.     theErr = AEInstallEventHandler ( kCoreEventClass, kAEOpenApplication, NewAEEventHandlerProc ( HandleOapp ), 0, false );
  58.     if ( theErr )    goto CleanupAndBail;
  59.  
  60.     theErr = AEInstallEventHandler ( kCoreEventClass, kAEOpenDocuments, NewAEEventHandlerProc ( HandleOdoc ), 0, false );
  61.     if ( theErr )    goto CleanupAndBail;
  62.  
  63.     theErr = AEInstallEventHandler ( kCoreEventClass, kAEPrintDocuments, NewAEEventHandlerProc ( HandlePdoc ), 0, false );
  64.     if ( theErr )    goto CleanupAndBail;
  65.  
  66.     theErr = AEInstallEventHandler ( kCoreEventClass, kAEQuitApplication, NewAEEventHandlerProc ( HandleQuit ), 0, false );
  67.     if ( theErr )    goto CleanupAndBail;
  68.     
  69.     
  70. CleanupAndBail:
  71.  
  72.     return theErr;
  73.     
  74. }    // InstallAppleEventHandlers
  75.  
  76.  
  77.  
  78. #pragma segment Core
  79.  
  80. static pascal OSErr HandleOapp ( AEDescList* aevt, AEDescList* reply, long refCon )
  81. {
  82.     return errAEEventNotHandled;
  83. }
  84.  
  85.  
  86.  
  87. static pascal OSErr HandleOdoc ( AEDescList* aevt, AEDescList* reply, long refCon )
  88. {
  89.     return errAEEventNotHandled;
  90. }
  91.  
  92.  
  93.  
  94. static pascal OSErr HandlePdoc ( AEDescList* aevt, AEDescList* reply, long refCon )
  95. {
  96.     return errAEEventNotHandled;
  97. }
  98.  
  99.  
  100.  
  101. static pascal OSErr HandleQuit ( AEDescList* aevt, AEDescList* reply, long refCon )
  102. {
  103.     gQuit = true;
  104.     
  105.     return noErr;
  106. }
  107.  
  108.  
  109.  
  110.  
  111.